package com.cj.designpattern.adapter;

import com.cj.designpattern.adapter.common.IVoltage5;
import com.cj.designpattern.adapter.common.Voltage220;

/**
 * ClassName: ObjectVoltageAdapter <br/>
 * Function: 对象适配器 <br/>
 * date: 2018/04/28 9:55 <br/>
 *
 * @author chenj
 * @version 1.0.0
 * @since JDK 1.8
 */
public class ObjectVoltageAdapter implements IVoltage5 {

    private Voltage220 voltage220;

    public ObjectVoltageAdapter(Voltage220 voltage220) {
        this.voltage220 = voltage220;
    }

    @Override
    public int outPut5V() {
        int dst = 0;
        if (null != voltage220) {
            int src = voltage220.outPut220V();
            System.out.println("对象适配器工作，开始适配电压");
            dst = src / 44;
            System.out.println("适配完成后输出电压：" + dst);
        }
        return dst;
    }
}
